#include "mainscence.h"
#include "ui_mainscence.h"
#include <QPainter>

MainScence::MainScence(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainScence)
{
    ui->setupUi(this);

    // 固定界面大小
    this->setFixedSize(320,588);

    //设置图标
    setWindowIcon(QIcon(":/res/Coin0001.png"));

    // 设置标题
    setWindowTitle("翻金币游戏");

    // 退出
    connect(ui->menu,&QAction::triggered,[=](){
        this->close();
    });

}

MainScence::~MainScence()
{
    delete ui;
}

// 绘图事件
void MainScence::paintEvent(QPaintEvent*)
{
    //画背景图
    QPainter pain(this);
    QPixmap pix;
    pix.load(":/res/PlayLevelSceneBg.png");
    pain.drawPixmap(0,0,this->width(),this->height(),pix);

    //加载左上角标题图片
    pix.load(":/res/Title.png");

    //缩放图片
    pix =  pix.scaled(pix.width()*0.5, pix.height()*0.5);

    pain.drawPixmap(10,30,pix);

}
